<template>
  <el-main>
    <el-table
        :data="tableData"
        style="width: 100%"
        :row-class-name="tableRowClassName">
      <el-table-column
          prop="name"
          label="序号"
          width="50">
        <template slot-scope="scope">
          {{scope.$index+1}}
        </template>
      </el-table-column>
      <el-table-column
          prop="comAddress"
          label="合同名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="dateStart"
          label="合同日期"
          width="180">
      </el-table-column>
      <el-table-column
          prop="dateEnd"
          label="合同日期"
          width="180">
      </el-table-column>
      <el-table-column
          prop="total"
          label="合同金额">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="danger"
              @click="check(scope.row)">提交审核</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row>
      <el-col :span="6">
        <!--<el-button type="primary" @click="add">添加</el-button>
        <el-button type="primary" @click="pdf">导出pdf</el-button>-->
      </el-col>
    </el-row>

  </el-main>
</template>

<script>
export default {
  name: "HeTong",
  data() {
    return {
      tableData: [],
    }
  },
  methods: {
    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 1) {
        return 'warning-row';
      } else if (rowIndex === 3) {
        return 'success-row';
      }
      return '';
    },

    check(row) {
      this.axios.get('contract/startProcessInstanceById', {params: {id: row.id}}).then(res => {
        this.$message.success('已提交审核');
      });

    },

    pageQuery() {
      this.axios.get('/contract/list', {params: this.queryForm}).then(res => {
        this.tableData = res.data.data
      });
    }
  },
  mounted() {
    this.pageQuery();
  }
}
</script>

<style scoped>
.el-row {
  margin-top: 20px;
}
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>